﻿// -----------------------------------------------------------------------
// <copyright file="PlayableTileConverter.cs" company="R&R">
// TODO: Update copyright text.
// </copyright>
// -----------------------------------------------------------------------

#region Imports
using System;
using System.Globalization;
using System.Windows.Data;
#endregion Imports

namespace Domino
{
    public class PlayableTileConverter : IValueConverter
    {
        #region IValueConverter Members
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            bool isPlayable = false;
            Boolean.TryParse(System.Convert.ToString(value), out isPlayable);

            double opacity = -1;
            if (!Double.TryParse(System.Convert.ToString(parameter), out opacity)) opacity = 1;

            return isPlayable ? 1 : opacity;
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
        #endregion IValueConverter Members
    }
}
